<?
function connecttodb($servername,$dbname,$dbuser,$dbpassword)
{
    global $link;
    $link=mysql_connect("$servername","$dbuser","$dbpassword");
    if(!$link){ ?> 
        <script type="text/javascript">
          alert("Couldn't Connect to the mySQL database. We've got issues!");
        </script> 
        <?php
        die("Could not connect to MySQL");  
   }
   mysql_select_db("$dbname", $link) or die ("could not open db".mysql_error());
}
?>
